Skip to content

fix(NO/SAF-T): skip currency info export when currency equals LCY code#29959

Open
jeffreybulanadi wants to merge 1 commit intomicrosoft:mainfrom
jeffreybulanadi:fix/26554-no-saft-skip-lcy-currency-export
Open

fix(NO/SAF-T): skip currency info export when currency equals LCY code#29959
jeffreybulanadi wants to merge 1 commit intomicrosoft:mainfrom
jeffreybulanadi:fix/26554-no-saft-skip-lcy-currency-export

Conversation

@jeffreybulanadi
Copy link
Copy Markdown

@jeffreybulanadi jeffreybulanadi commented Apr 21, 2026

Summary

When exporting SAF-T (both v1.0 and v1.3), if a Bank Account Ledger Entry (or Customer/Vendor Ledger Entry) has a Currency Code that equals the company LCY code, the export was incorrectly writing CurrencyCode, CurrencyAmount, and ExchangeRate XML nodes for what is effectively a domestic currency entry.

The root cause is in GetFCYData: after checking for a blank Currency Code, the function did not check whether the currency equals the LCY code. A bank account explicitly configured with LCY code (e.g. NOK on a Norwegian company) would pass the blank-check and inject spurious currency XML on all G/L entries in the same transaction.

Changes

  • Added GeneralLedgerSetup.Get() in GetFCYData, called once after the Export Currency Information guard.
  • Added an LCY code guard in each ledger-entry branch (Customer, Vendor, Bank Account): if the retrieved Currency Code equals GeneralLedgerSetup.LCY Code, exit immediately.
  • The LCY guard is placed before CalcFields to avoid an unnecessary database round-trip when it triggers.
  • Applied identically to both GenerateSAFTFile.Codeunit.al (codeunit 10673, SAF-T v1.0) and GenerateSAFT13File.Codeunit.al (codeunit 10692, SAF-T v1.3).

Related Issue

Fixes #26554

Fixes AB#632882

In GetFCYData, when a Customer, Vendor, or Bank Account Ledger Entry
has a Currency Code that equals the company LCY code, the export was
incorrectly including CurrencyCode, CurrencyAmount, and ExchangeRate
XML nodes in the SAF-T output.

Add GeneralLedgerSetup.Get() once after the Export Currency Information
guard, then bail out early in each ledger-entry branch when the
retrieved currency code matches the LCY code. The early exit is placed
before CalcFields to avoid an unnecessary database round-trip.

Applied identically to both SAF-T v1.0 (codeunit 10673) and
SAF-T v1.3 (codeunit 10692).

Fixes microsoft#26554
@jeffreybulanadi jeffreybulanadi requested a review from a team as a code owner April 21, 2026 15:08
@JesperSchulz JesperSchulz added Finance GitHub request for Finance area linked Issue is linked to a Azure Boards work item labels Apr 24, 2026
@JesperSchulz
Copy link
Copy Markdown
Contributor

@jeffreybulanadi, could you add some tests? Then I'll process 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Finance GitHub request for Finance area linked Issue is linked to a Azure Boards work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Norwegian SAF-T file repeats the same amount when Entry has a Currency Code

2 participants